﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BDShop.Entities;
using BDShop.Business.Cache;

namespace BDShop.Business
{
    public class EmailService
    {
        public static EmailComplex Init()
        {
            EmailComplex email=new EmailComplex();
            email.SMTP = ConfigCache.Instance.Get().Where(c => c.Key.ToUpper() == "SMTP").FirstOrDefault().Value;
            email.Port = int.Parse(ConfigCache.Instance.Get().Where(c => c.Key.ToUpper() == "PORT").FirstOrDefault().Value);
            email.UserName = ConfigCache.Instance.Get().Where(c => c.Key.ToUpper() == "USERNAME").FirstOrDefault().Value;
            email.Password = ConfigCache.Instance.Get().Where(c => c.Key.ToUpper() == "PASSWORD").FirstOrDefault().Value;
            email.From = ConfigCache.Instance.Get().Where(c => c.Key.ToUpper() == "FROM").FirstOrDefault().Value;
            email.IsBodyHtml = Boolean.Parse(ConfigCache.Instance.Get().Where(c => c.Key.ToUpper() == "ISBODYHTML").FirstOrDefault().Value);
            email.EnableSsl = Boolean.Parse(ConfigCache.Instance.Get().Where(c => c.Key.ToUpper() == "ENABLESSL").FirstOrDefault().Value);

            return email;
        }
    }
}
